<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/public/js/html5shiv.js"></script>
    <script type="text/javascript" src="/public/js/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/Hui-iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/public/plugins/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="/public/js/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>角色列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 角色列表 <a class="btn btn-success radius refresh r" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray title-action">
         <span class="r">
        <?php if ($auth['group_add']): ?><a href="<?php echo site_url('auth/group_add') ?>" class="btn btn-primary radius edit"><i class="Hui-iconfont">&#xe600;</i> 添加角色</a><?php endif ?>
         </span>
    </div>
    <?php $auth_action = $auth['access'] || $auth['group_edit'] || $auth['group_del'] ?>
    <table class="table table-border table-bordered table-bg" id="dataTables">
        <thead>
        <tr class="text-c">
            <th>名称</th>
            <th>状态</th>
            <th>用户数</th>
            <?php if ($auth_action): ?><th style="width:120px">操作</th><?php endif ?>
        </tr>
        </thead>
    </table>
</div>
<script type="text/javascript" src="/public/js/jquery.min.js"></script>
<script type="text/javascript" src="/public/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/public/plugins/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/public/plugins/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript">
    var dataTables = $('#dataTables').my_data_table({
        columns: [
            {data: 'title'},
            {data: 'status', render: function (data, type, row, meta) {return data==0?'待审核':(data==1?'已启用':'已删除')}},
            {data: 'users', searchable: false, orderable: false, render: function (data, type, row, meta) {
                return <?php if ($auth['user_index']): ?>'<a  onclick="Hui_admin_tab(this)" data-href="<?php echo site_url('user/index') ?>?group_id=' + row['id'] + '" data-title="用户列表">' + data + '</a>'<?php else: ?>data<?php endif ?>;
            }},
            <?php if ($auth_action): ?>
            {data: 'id', searchable: false, orderable: false, render: function (data, type, row, meta) {
                var status = parseInt(row['status']), html = '';
                <?php if ($auth['access']): ?>html += '<a href="<?php echo site_url('auth/access') ?>?id=' + data + '" class="rule">设置权限</a> ';<?php endif ?>
                <?php if ($auth['group_edit']): ?>html += '<a href="<?php echo site_url('auth/group_edit') ?>?id=' + data + '" class="edit">编辑</a> ';<?php endif ?>
                <?php if ($auth['group_del']): ?>
                if (status === 3) html += '<a href="<?php echo site_url('auth/group_del') ?>?id=' + data + '" class="del">启用</a> ';
                else html += '<a href="<?php echo site_url('auth/group_del') ?>?id=' + data + '" class="del">删除</a> ';
                <?php endif ?>
                return html;
            }}
            <?php endif ?>
        ]
    });

    $("#dataTables tbody,.title-action").on("click", ".edit", function() {
        var obj = $(this), url = obj.attr('href'), txt = obj.text().replace('角色', '') + '角色';
        layer.open({type: 2, title: '用户添加', shadeClose: true, shade: 0.8, area: ['80%', '80%'], maxmin: true, content: url});
        return false;
    }).on("click", ".del", function() {
        var obj = $(this), url = obj.attr('href'), txt = obj.text();
        var index = layer.confirm('您确定要' + txt + '此角色吗？', function(){
            return $.change_status({url: url, layer: layer, index: index});
        });
        return false;
    }).on("click", ".rule", function() {
        var obj = $(this), url = obj.attr('href'), txt = obj.text();
        layer.open({type: 2, title: txt, shadeClose: true, shade: 0.8, area: ['80%', '80%'], maxmin: true, content: url});
        return false;
    });
</script>
</body>
</html>